﻿@page "/home"
@page "/"
@using MXERP.Shared.Extensions
@attribute [Authorize]
@inject IStringLocalizer<Index> L
<View>
    <ButtonContent>
        <MudButton Variant="Variant.Filled" Color="Color.Default">Default</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Primary">Primary</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Secondary">Secondary</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Tertiary">Tertiary</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Info">Info</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Success">Success</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Warning">Warning</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Error">Error</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Dark">Dark</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Transparent">Transparent</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Inherit">Inherit</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Surface">Surface</MudButton>
        <MudButton Variant="Variant.Filled" Disabled="true">Disabled</MudButton>
    </ButtonContent>
    <ChildContent>
        <MudDataGrid Class="mud-height-full" Items="@_apps" Virtualize Height="100%">
            <Columns>
                <MudBlazor.SelectColumn T="AppTreeResponse" />
                <MudBlazor.PropertyColumn Property="x => x.Title" Title="应用名称" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.Icon" Title="图标" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.Name" Title="路由名称" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.Type" Title="类型" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.Path" Title="路由路径" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.Component" Title="组件名称" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.License" Title="许可证" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.IsKeepAlive" Title="是否缓存" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.IsAffix" Title="是否固定" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.IsMultiTab" Title="是否支持多个tab页签" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.IsHide" Title="是否隐藏" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.IsIframe" Title="是否内嵌" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.IsLink" Title="是否外链" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.Sort" Title="排序" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.Remark" Title="备注" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.CreatedByName" Title="创建人" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.CreatedOn" Title="创建时间" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.UpdatedByName" Title="更新人" Width="300" />
                <MudBlazor.PropertyColumn Property="x => x.UpdatedOn" Title="更新时间" Width="300" />
            </Columns>
        </MudDataGrid>
    </ChildContent>
    <PaginationContent>
        <MudPagination Rectangular="true" Variant="Variant.Filled" BoundaryCount="2" MiddleCount="5" Count="22" />
    </PaginationContent>
</View>
    

@code {

    [Inject]
    public IAppManager AppManager { get; set; } = default!;
    [Inject]
    public MapsterMapper.IMapper Mapper { get; set; } = default!;
    private List<AppTreeResponse>? _apps;
    protected override async Task OnInitializedAsync()
    {
        var result = await AppManager.Query();
        var data = Mapper.Map<List<AppTreeResponse>>(result.Data);
        _apps = data.ToTree();
    }
}